package cn.fuxi2022.model.empty.accounts;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 微信公众号菜单表
 * </p>
 *
 * @author Fuxi
 * @since 2022-10-18 14:57:39
 */
@Getter
@Setter
@TableName("accounts_menu")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class AccountsMenu implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 编号
     */
    @NotNull(message = "ID不能为空", groups = AccountsMenu.Update.class)
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;

    /**
     * 上级id
     */
    @NotNull(message = "上级ID不能为空", groups = {AccountsMenu.Save.class, AccountsMenu.Update.class})
    @TableField("parent_id")
    private String parentId;

    /**
     * 菜单名称
     */
    @NotNull(message = "菜单名称不能为空", groups = {AccountsMenu.Save.class, AccountsMenu.Update.class})
    @TableField("menu_name")
    private String menuName;

    /**
     * 类型（click：点击后，事件通过消息接口推送消息 view：跳转网页 miniprogram：跳转至小程序（url:固定http://mp.weixin.qq.com、appid、pagepath：页面链接））
     */
    @TableField("type")
    private String type;

    /**
     * KEY值，用于消息接口推送
     */
    @TableField("menu_key")
    private String menuKey;

    /**
     * 链接（网页链接 或小程序页面链接）
     */
    @TableField("url")
    private String url;

    /**
     * 排序
     */
    @Min(value = 0, message = "排序不能比0小", groups = {AccountsMenu.Save.class, AccountsMenu.Update.class})
    @NotNull(message = "排序不能为空", groups = {AccountsMenu.Save.class, AccountsMenu.Update.class})
    @TableField("sort")
    private Integer sort;

    @TableField(exist = false)
    private List<AccountsMenu> children;

    /**
     * 逻辑删除 1（true）已删除， 0（false）未删除
     */
    @JsonIgnore
    @TableLogic(value = "0", delval = "1")
    @TableField("is_deleted")
    private Integer isDeleted;

    /**
     * 创建时间
     */
    @JsonIgnore
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @JsonIgnore
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    public interface Update {
    }

    public interface Save {
    }
}
